<template>
  <div class="page">
    <div class="weui-cells weui-cells_form">
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <div class="starrow">门店环境：<rate :number="environment" :readonly="false"></rate></div>
          <div class="starrow">技师礼仪：<rate :number="etiquette" :readonly="false"></rate></div>
          <div class="starrow">技师技能：<rate :number="skills" :readonly="false"></rate></div>
          <div class="starrow">产品效果：<rate :number="effect" :readonly="false"></rate></div>
          <div class="starrow">总和评分：<rate :number="comprehensive" :readonly="false"></rate></div>
          <textarea class="weui-textarea mytextarea" v-model="content" placeholder="请输入文本" rows="3"></textarea>
        </div>
      </div>
    </div>
    <div class="footbtn">
      <a  @click="submitFun">保存</a>
    </div>
  </div>
</template>

<script>
import rate from '../../components/rate'
export default {
  data () {
    return {
      star: 4,
      content:"",
      environment:5,
      etiquette:5,
      skills:5,
      effect:5,
      comprehensive:5,
      options:{}
    }
  },
  onLoad(options){
   this.options=options
  },
  onShow(){
    wx.setNavigationBarTitle({
      title: "评论"
    })
    this.content="";
    this.environment=5;
      this.etiquette=5;
      this.skills=5;
      this.effect=5;
      this.comprehensive=5;
  },
  components: {
    rate
  },
  methods: {
    submitFun(){
       console.log(this.content)
      this.$http.request({
        method:"post",
        url:"/v1.0/appletLogin/orderEvaluate",
        body:{
          content:this.content,
          environment:this.environment,
          etiquette:this.etiquette,
          skills:this.skills,
          effect:this.effect,
          comprehensive:this.comprehensive,
          productId:this.options.productId,
          cardId:this.options.cardId,
          stuffId:this.options.stuffId
        }
      }).then((data)=>{
        if(data.code==0){
          wx.showToast({
            title: '评论成功!',
            icon: 'success',
            duration: 2000
          })
          setTimeout(()=>{
            wx.navigateBack({

            })
          },500)
        }else{
          wx.showToast({
            title: `${data.message}`,
            icon: 'none',
            duration: 2000
          })
        }
      })
    }
  },

  created () {
    // let app = getApp()
  }
}
</script>

<style scoped>
.page{
  padding-bottom: 4em;
}
.mytextarea{
  margin-top: 0.4em;
  background: #f6f6f6;
  border: 1px #e5e5e5 solid;
  border-radius: 0.3em;
}
.footbtn{
  position: fixed;
  bottom: 0px;
  left: 0px;
  right: 0px;
  background: #fff;
  border-top: 1px #eee solid;
  padding: 0.6em 2em;
  z-index: 9999;
}
.footbtn a{
  display: block;
  height: 2.4em;
  border-radius: 1.2em;
  background: #FF787E;
  color: #fff;
  line-height: 2.4em;
  text-align: center;
  color: #fff;
  font-size: 1em;
}
.starrow{
  font-size: 0.9em;
}
</style>
